<?php

class Core_Backend_Component_Permission_View_Action_Create extends Core_Backend_Share_View_Form {

    protected function buildToolbar($toolbar) {
        $group = $toolbar->createGroup('back');
        $group->addLink($this->getHistoryUrl('permission/action/index'), $this->__('share.button.back'));
        $group = $toolbar->createGroup('save');
        $group->addButton($this->__('share.button.save'))
                ->bindEvent('click', "Kdf.Ui.getForm('" . $this->getForm()->getId() . "').submit('" . $this->getUrl(NULL, 'save') . "')");
        parent::buildToolBar($toolbar);
    }

    protected function buildForm($form) {
        $entity = $this->getModel(NULL);
        $form->setAction($this->getUrl())
                ->setId('action_form')
                ->addHiddenField('id', 'action[id]')
                ->addHiddenField('area_id', 'action[area_id]', $this->getSession()->get('managed_area_id'));
        $form->addTextboxField($this->__('share.label.code'), 'code', 'action[code]', TRUE)
                ->addMultiRule('required', 'character');
        $form->addTextboxField($this->__('share.label.name'), 'name', "action[name]", TRUE);
        $form->addTextboxField($this->__('share.label.group'), 'group', "action[group]", TRUE);
        $form->addSelectField($this->__('permission.label.isavailable'), 'status', 'action[status]', TRUE)
                ->setOption($this->__('status.boolean.1'),'enabled')
                ->setOption($this->__('status.boolean.0'),'disabled');                
        if (!is_null($entity)) {
            $form->bindData($entity->getAllData());
        }
        parent::buildForm($form);
    }

}